package com.lyx.db137.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lyx.db137.common.R;
import com.lyx.db137.entity.Userrole;
import com.lyx.db137.service.UserroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: zero domain
 * @CreateTime: 2025/1/3 11:34
 * @Description: TODO
 * @Version: 1.0
 */

/**
 * userrole
 */
@CrossOrigin(origins = "*")
@RestController
public class UserRoleController {
    @Autowired
    UserroleService userroleService;
    @PostMapping("deleteByUseridAndRoleid")
    public R deleteByUseridAndRoleid(@RequestBody Userrole userrole){
        UpdateWrapper<Userrole> userroleUpdateWrapper = new UpdateWrapper<>();
        userroleUpdateWrapper.setEntity(userrole);
        this.userroleService.remove(userroleUpdateWrapper);
//        System.out.println(userrole.getUserid()+"==="+userrole.getRoleid());
        return new R();
    }
    @RequestMapping("addRoleid")
    public R addRoleid(@RequestBody Userrole userrole){
       return new R().add("role",this.userroleService.insert(userrole));
    }
}
